﻿using BusinessLogic.DBUtility;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace BusinessLogic
{
   public class LoginLogic
    {
        public DataSet LogOn(string LoginName, string LoginPwd, string LoginIp)
        {
            SqlParameter[] parameters = {
                    new SqlParameter("@LoginName",SqlDbType.VarChar,20), 
                    new SqlParameter("@Password",SqlDbType.VarChar,36),
                    new SqlParameter("@LoginIp",SqlDbType.VarChar,50)
                                       };
            parameters[0].Value = LoginName;
            parameters[1].Value = LoginPwd;
            parameters[2].Value = LoginIp;
            DataSet ds = null;

            SqlConnection connection = new SqlConnection(DAConfig.ConnStringToDtmisDb);
            try
            {
                ds = SqlHelper.ExecuteDataset(connection, CommandType.StoredProcedure, "sp_Sys_AdminUserLogOn", parameters);
            }
            catch
            {
                throw;
            }
            finally
            {
                if (connection != null)
                {
                    connection.Dispose();
                }
            }
            return ds;

        }
    }
}
